css: Implement "unset"
authorBenjamin Otte <otte@redhat.com>
Sun, 11 May 2014 01:08:40 +0000 (03:08 +0200)
committerBenjamin Otte <otte@redhat.com>
Sun, 11 May 2014 01:23:55 +0000 (03:23 +0200)
Quoting the spec:
  If the cascaded value of a property is the unset keyword,
  then if it is an inherited property, this is treated as
  inherit, and if it is not, this is treated as initial.

Spec in question:
  http://dev.w3.org/csswg/css-cascade/

Also use unset in the reset-to-defaults.css we use to reset css in
reftests.

gtk/Makefile.am
gtk/gtkcssinheritvalue.c
gtk/gtkcssinheritvalueprivate.h
gtk/gtkcssshorthandproperty.c
gtk/gtkcssstyleproperty.c
testsuite/reftests/reset-to-defaults.css

index e3fa20277a61b6afa42de11a8020436a7e8c6fc4..38a2492da8231a0b63c799af883fd5781450f0a5 100644 (file)
@@ -483,6 +483,7 @@ gtk_private_h_sources =             \
        gtkcssstylepropertyprivate.h \
        gtkcsstransitionprivate.h       \
        gtkcsstypedvalueprivate.h       \
+       gtkcssunsetvalueprivate.h       \
        gtkcssvalueprivate.h    \
        gtkcustompaperunixdialog.h \
        gtkdialogprivate.h      \
@@ -731,6 +732,7 @@ gtk_base_c_sources =                \
        gtkcssstylepropertyimpl.c \
        gtkcsstransition.c      \
        gtkcsstypedvalue.c      \
+       gtkcssunsetvalue.c      \
        gtkcssvalue.c           \
        gtkcsstypes.c           \
        gtkdialog.c             \
index 053245cf734160a9a36dc19e4cc32c50ea8b6129..bfea779d69b660fbf652dc9f2e862d4b4b9f4dfb 100644 (file)
@@ -97,3 +97,9 @@ _gtk_css_inherit_value_new (void)
 {
   return _gtk_css_value_ref (&inherit);
 }
+
+GtkCssValue *
+_gtk_css_inherit_value_get (void)
+{
+  return &inherit;
+}
index ae69a6b7cf7abbb487b03ee8740cecece93b017e..6c7fe8a83890d84771fc72c11925f55186b54c25 100644 (file)
@@ -25,6 +25,7 @@
 G_BEGIN_DECLS
 
 GtkCssValue *   _gtk_css_inherit_value_new            (void);
+GtkCssValue *   _gtk_css_inherit_value_get            (void);
 
 G_END_DECLS
 
index c6ca6146890cae4c12db2c4dab906d319805657a..68bb064a102fd1416f92245a690f732efa4ccc83 100644 (file)
@@ -25,6 +25,7 @@
 #include "gtkcssinheritvalueprivate.h"
 #include "gtkcssinitialvalueprivate.h"
 #include "gtkcssstylefuncsprivate.h"
+#include "gtkcssunsetvalueprivate.h"
 #include "gtkintl.h"
 
 enum {
@@ -118,6 +119,17 @@ gtk_css_shorthand_property_parse_value (GtkStyleProperty *property,
           data[i] = _gtk_css_inherit_value_new ();
         }
     }
+  else if (_gtk_css_parser_try (parser, "unset", TRUE))
+    {
+      /* If the cascaded value of a property is the unset keyword,
+       * then if it is an inherited property, this is treated as
+       * inherit, and if it is not, this is treated as initial.
+       */
+      for (i = 0; i < shorthand->subproperties->len; i++)
+        {
+          data[i] = _gtk_css_unset_value_new ();
+        }
+    }
   else if (!shorthand->parse (shorthand, data, parser))
     {
       for (i = 0; i < shorthand->subproperties->len; i++)
index e2bfa77a163513ffd8b88c41ada6f2e17392531e..5053892430424901c32b0a1fa4bbe474eaff1198 100644 (file)
@@ -26,6 +26,7 @@
 #include "gtkcssinitialvalueprivate.h"
 #include "gtkcssstylefuncsprivate.h"
 #include "gtkcsstypesprivate.h"
+#include "gtkcssunsetvalueprivate.h"
 #include "gtkintl.h"
 #include "gtkprivatetypebuiltins.h"
 #include "gtkstylepropertiesprivate.h"
@@ -255,6 +256,14 @@ gtk_css_style_property_parse_value (GtkStyleProperty *property,
        */
       return _gtk_css_inherit_value_new ();
     }
+  else if (_gtk_css_parser_try (parser, "unset", TRUE))
+    {
+      /* If the cascaded value of a property is the unset keyword,
+       * then if it is an inherited property, this is treated as
+       * inherit, and if it is not, this is treated as initial.
+       */
+      return _gtk_css_unset_value_new ();
+    }
 
   return (* style_property->parse_value) (style_property, parser);
 }
index 1c27a8e72b2dc2edf387858439e9508f4e15da93..8654a5bf0fda283b828231a9e9652072b0696f26 100644 (file)
@@ -7,60 +7,60 @@
  */
 
 * {
-  color: inherit;
-  font-size: inherit;
-  background-color: initial;
-  font-family: inherit;
-  font-style: inherit;
-  font-variant: inherit;
-  font-weight: inherit;
-  text-shadow: inherit;
-  icon-shadow: inherit;
-  box-shadow: initial;
-  margin-top: initial;
-  margin-left: initial;
-  margin-bottom: initial;
-  margin-right: initial;
-  padding-top: initial;
-  padding-left: initial;
-  padding-bottom: initial;
-  padding-right: initial;
-  border-top-style: initial;
-  border-top-width: initial;
-  border-left-style: initial;
-  border-left-width: initial;
-  border-bottom-style: initial;
-  border-bottom-width: initial;
-  border-right-style: initial;
-  border-right-width: initial;
-  border-top-left-radius: initial;
-  border-top-right-radius: initial;
-  border-bottom-right-radius: initial;
-  border-bottom-left-radius: initial;
-  outline-style: initial;
-  outline-width: initial;
-  outline-offset: initial;
-  background-clip: initial;
-  background-origin: initial;
-  background-size: initial;
-  background-position: initial;
-  border-top-color: initial;
-  border-right-color: initial;
-  border-bottom-color: initial;
-  border-left-color: initial;
-  outline-color:  initial;
-  background-repeat: initial;
-  background-image: initial;
-  border-image-source: initial;
-  border-image-repeat: initial;
-  border-image-slice: initial;
-  border-image-width: initial;
-  transition-property: initial;
-  transition-duration: initial;
-  transition-timing-function: initial;
-  transition-delay: initial;
-  engine: initial;
-  gtk-key-bindings: initial;
+  color: unset;
+  font-size: unset;
+  background-color: unset;
+  font-family: unset;
+  font-style: unset;
+  font-variant: unset;
+  font-weight: unset;
+  text-shadow: unset;
+  icon-shadow: unset;
+  box-shadow: unset;
+  margin-top: unset;
+  margin-left: unset;
+  margin-bottom: unset;
+  margin-right: unset;
+  padding-top: unset;
+  padding-left: unset;
+  padding-bottom: unset;
+  padding-right: unset;
+  border-top-style: unset;
+  border-top-width: unset;
+  border-left-style: unset;
+  border-left-width: unset;
+  border-bottom-style: unset;
+  border-bottom-width: unset;
+  border-right-style: unset;
+  border-right-width: unset;
+  border-top-left-radius: unset;
+  border-top-right-radius: unset;
+  border-bottom-right-radius: unset;
+  border-bottom-left-radius: unset;
+  outline-style: unset;
+  outline-width: unset;
+  outline-offset: unset;
+  background-clip: unset;
+  background-origin: unset;
+  background-size: unset;
+  background-position: unset;
+  border-top-color: unset;
+  border-right-color: unset;
+  border-bottom-color: unset;
+  border-left-color: unset;
+  outline-color:  unset;
+  background-repeat: unset;
+  background-image: unset;
+  border-image-source: unset;
+  border-image-repeat: unset;
+  border-image-slice: unset;
+  border-image-width: unset;
+  transition-property: unset;
+  transition-duration: unset;
+  transition-timing-function: unset;
+  transition-delay: unset;
+  engine: unset;
+  gtk-key-bindings: unset;
 
   -GtkWidget-focus-line-width: 0;
   -GtkWidget-focus-padding: 0;